<?php
	require_once( 'core_DataBaseConnect.php' );
	require_once( 'core_ErrorCode.php' );
	require_once( 'core_Response.php' );
	require_once( 'dao_ModelDAO.php' );
	require_once( 'dao_MemberModelDAO.php' );
	require_once( '_configs.php' );
	
	function func( $con, $post, $returnType )
	{
		// 0. 작성 권한 설정 ( 회원 )
		if( MemberDAO::isAccessable( $con, $post[ 'login_member_id' ], array( configs::AUTHOR_ADMIN, configs::AUTHOR_MANAGER, configs::AUTHOR_MEMBER ) ) == false )
		{
			// 작성권한 없음
			return Response::FAIL( ErrorCode::FAIL_WRITE_AUTHOR, "작성권한이 없습니다. 회원만 가능합니다.", $returnType );
		}
		
		
		// 1. 전체 모델 수
		$response = array();
		$response[ 'count' ] = MemberModelDAO::countFavoriteModels( $con, $post[ 'login_member_id' ] );
		
		// 2. 조회
		$result = MemberModelDAO::selectFavoriteModels( $con, $post[ 'login_member_id' ], $post[ 'page' ], $post[ 'numPerPage' ] );
		$response[ 'model' ] = array();
		while( $fetch = DataBaseConnect::fetch_assoc( $result ) )
		{
			array_push( $response[ 'model' ], DataBaseConnect::fetchSerialize( $fetch, array( 'SEQ', 'CODE', 'NAME', 'PICTURE', 'BIRTH_DATE', 'BIRTH_REGION', 'LAST_EDU', 'SEX', 'MILITARY', 'HEIGHT', 'REF', 'REF_LICENSE' ) ) );
		}
		
		return Response::SUCCESS( $response, $returnType );
	}
?>